﻿using Code.Services.Roles;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace CodeAPP.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    [Authorize(Roles = "RoleManager")]
    public class RoleController : ControllerBase
    {
        private readonly IRoleService service;

        public RoleController(IRoleService service)
        {
            this.service = service;
        }

        [HttpGet("/Role/QueryAll")]
        public IActionResult QueryAll()
        {
            return new JsonResult(service.QueryAll());
        }

        [HttpGet("/Role/QueryByRoleId")]
        public IActionResult QueryPermission(int roleId)
        {
            return new JsonResult(service.QueryPermission(roleId));
        }
    }
}
